package editor.animation;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

public class ColoredListRenderer extends DefaultListCellRenderer {
	public void clear() {
		colors.clear();
	}

	public void add(int index, Color color) {
		colors.add(index, color);
	}

	public void remove(int index) {
		colors.remove(index);
	}

	public void set(int index, Color color) {
		colors.set(index, color);
	}

	public Color get(int index) {
		return colors.get(index);
	}

	@Override
	public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
		super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

		setForeground(colors.get(index));

		return this;
	}

	private ArrayList<Color> colors = new ArrayList<Color>();
}
